|
|
@ -79,201 +79,18 @@ public class UnplannedIssueRequestForDongyangAppService : UnplannedIssueRequestA |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
/// <summary>
|
|
|
|
/// OA创建计划外出库申请
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="input"></param>
|
|
|
|
/// <returns></returns>
|
|
|
|
[HttpPost("create-by-oa")] |
|
|
|
//[Authorize(UnplannedIssueRequestPermissions.Create)]
|
|
|
|
public override async Task<UnplannedIssueRequestDTO> CreateByOAAsync(UnplannedIssueRequestEditInput input) |
|
|
|
{ |
|
|
|
Logger.LogInformation($"DeptNmae【{input.DeptName}】,DeptCode【{input.DeptCode}】"); |
|
|
|
var entity = ObjectMapper.Map<UnplannedIssueRequestEditInput, UnplannedIssueRequest>(input); |
|
|
|
foreach (var item in entity.Details) |
|
|
|
{ |
|
|
|
await SetDetailPropertiesAsync(item, input.UnplannedIssueType).ConfigureAwait(false); |
|
|
|
} |
|
|
|
entity.AutoCompleteJob = false; |
|
|
|
entity.AutoSubmit = true; |
|
|
|
entity.AutoAgree = true; |
|
|
|
entity.AutoHandle = true; |
|
|
|
entity.DirectCreateNote = false; |
|
|
|
|
|
|
|
//var userEntity=await _userRepository.FindByNormalizedUserNameAsync(input.Worker).ConfigureAwait(false);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
await _unplannedIssueRequestManager.CreateAsync(entity).ConfigureAwait(false); |
|
|
|
|
|
|
|
var dto = ObjectMapper.Map<UnplannedIssueRequest, UnplannedIssueRequestDTO>(entity); |
|
|
|
return dto; |
|
|
|
} |
|
|
|
//public virtual async Task<string> GetUserNameByUserAsync(string worker)
|
|
|
|
//{
|
|
|
|
// var userList = await _userRepository.GetListAsync().ConfigureAwait(false);
|
|
|
|
// var userEntity = userList.First(p => p.Name == worker);
|
|
|
|
// return userEntity.UserName;
|
|
|
|
//}
|
|
|
|
|
|
|
|
private async Task SetEntityPropertiesAsync(UnplannedIssueRequest entity) |
|
|
|
{ |
|
|
|
var userName = CurrentUser.GetUserName_New(); |
|
|
|
var name = CurrentUser.GetUserName(); |
|
|
|
if (userName != null) |
|
|
|
{ |
|
|
|
var department = await _departmentApp.GetByUsernameAsync(userName).ConfigureAwait(false); |
|
|
|
|
|
|
|
if (department != null) |
|
|
|
{ |
|
|
|
entity.DeptCode = department.Code; |
|
|
|
entity.DeptName = department.Name; |
|
|
|
} |
|
|
|
entity.CreatorId = CurrentUser.Id; |
|
|
|
entity.Worker = name; |
|
|
|
} |
|
|
|
|
|
|
|
entity.BuildDate = DateTime.Now; |
|
|
|
|
|
|
|
//await SetRequestAutoPropertiesAsync(entity).ConfigureAwait(false);
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// OA接口
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="p_list"></param>
|
|
|
|
/// <returns></returns>
|
|
|
|
[HttpPost("create-dongyang")] |
|
|
|
|
|
|
|
public async Task<UnplannedIssueRequestDTO> CreateByAsync(List<UnplannedIssueRequestImportDto> p_list) |
|
|
|
public async Task<UnplannedIssueRequestDTO> CreateByOaAsync(List<UnplannedIssueRequestImportDto> p_list) |
|
|
|
{ |
|
|
|
UnplannedIssueRequestDTO request = new UnplannedIssueRequestDTO(); |
|
|
|
try |
|
|
|
{ |
|
|
|
return await CreateByDYOAsync(p_list, true).ConfigureAwait(false); |
|
|
|
} |
|
|
|
catch (Exception e) |
|
|
|
{ |
|
|
|
|
|
|
|
throw new UserFriendlyException(e.Message); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
protected async Task<UnplannedIssueRequestDTO> CreateByDYOAsync(List<UnplannedIssueRequestImportDto> p_list, bool isAutoSubmit = false) |
|
|
|
{ |
|
|
|
UnplannedIssueRequest request = new UnplannedIssueRequest(); |
|
|
|
if (p_list.Count == 0) |
|
|
|
{ |
|
|
|
throw new UserFriendlyException("导入内容为空请填写!"); |
|
|
|
} |
|
|
|
|
|
|
|
var first = p_list.FirstOrDefault(); |
|
|
|
|
|
|
|
request.SetId(GuidGenerator.Create()); |
|
|
|
request.AutoCompleteJob = false; |
|
|
|
request.AutoSubmit = isAutoSubmit; |
|
|
|
request.AutoAgree = true; |
|
|
|
request.AutoHandle = true; |
|
|
|
request.DirectCreateNote = false; |
|
|
|
request.DeptCode = first.DeptCode; |
|
|
|
request.DeptName = first.DeptName; |
|
|
|
request.BuildDate = DateTime.Now; |
|
|
|
request.OANumber = first.OANumber; |
|
|
|
//request.Worker = first.Worker;
|
|
|
|
|
|
|
|
await SetEntityPropertiesAsync(request).ConfigureAwait(false); |
|
|
|
List<UnplannedIssueRequestDetail> detailList = new List<UnplannedIssueRequestDetail>(); |
|
|
|
foreach (var itm in p_list) |
|
|
|
{ |
|
|
|
var detail = new UnplannedIssueRequestDetail(); |
|
|
|
detail.ItemCode = itm.ItemCode; |
|
|
|
detail.Qty = itm.Qty; |
|
|
|
|
|
|
|
detail.LocationErpCode = itm.FromLocationErpCode; |
|
|
|
detail.LocationCode = "Random"; |
|
|
|
detail.WarehouseCode = "Random"; |
|
|
|
detail.LocationGroup = "Random"; |
|
|
|
detail.LocationArea = "Random"; |
|
|
|
detail.CaseCode = first.CaseCode; |
|
|
|
detail.ProjCapacityCode = first.ProjCapacityCode; |
|
|
|
detail.OnceBusiCode = first.OnceBusiCode; |
|
|
|
detail.Explain = first.Explain; |
|
|
|
detail.ExpireDate = DateTime.MaxValue; |
|
|
|
|
|
|
|
await SetDetailPropertiesAsync(detail).ConfigureAwait(false); |
|
|
|
detailList.Add(detail); |
|
|
|
} |
|
|
|
|
|
|
|
request.Details = detailList; |
|
|
|
|
|
|
|
|
|
|
|
//var user = await _sfsUserAppService.FindUserByUserNameAsync(first.Worker).ConfigureAwait(false);
|
|
|
|
//if (string.IsNullOrEmpty(user))
|
|
|
|
//{
|
|
|
|
// throw new UserFriendlyException("没有查到用户");
|
|
|
|
//}
|
|
|
|
request.Worker = first.Worker; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
await _unplannedIssueRequestManager.CreateAsync(request).ConfigureAwait(false); |
|
|
|
var dto = ObjectMapper.Map<UnplannedIssueRequest, UnplannedIssueRequestDTO>(request); |
|
|
|
return dto; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
protected async Task<UnplannedIssueRequestDTO> CreateByDYOAsync(List<UnplannedIssueRequestImportInput> p_list, bool isAutoSubmit=false) |
|
|
|
{ |
|
|
|
UnplannedIssueRequest request = new UnplannedIssueRequest(); |
|
|
|
if (p_list.Count == 0) |
|
|
|
{ |
|
|
|
throw new UserFriendlyException("导入内容为空请填写!"); |
|
|
|
} |
|
|
|
|
|
|
|
var first = p_list.FirstOrDefault(); |
|
|
|
|
|
|
|
request.SetId(GuidGenerator.Create()); |
|
|
|
request.AutoCompleteJob = false; |
|
|
|
request.AutoSubmit = isAutoSubmit; |
|
|
|
request.AutoAgree = false; |
|
|
|
request.AutoHandle = false; |
|
|
|
request.DirectCreateNote = false; |
|
|
|
|
|
|
|
request.BuildDate= DateTime.Now; |
|
|
|
|
|
|
|
|
|
|
|
await SetEntityPropertiesAsync(request).ConfigureAwait(false); |
|
|
|
List<UnplannedIssueRequestDetail> detailList = new List<UnplannedIssueRequestDetail>(); |
|
|
|
foreach (var itm in p_list) |
|
|
|
{ |
|
|
|
var detail = new UnplannedIssueRequestDetail(); |
|
|
|
detail.ItemCode = itm.ItemCode; |
|
|
|
detail.Qty = itm.Qty; |
|
|
|
|
|
|
|
detail.LocationErpCode = itm.FromErpLocationCode; |
|
|
|
detail.LocationCode = "Random"; |
|
|
|
detail.WarehouseCode ="Random"; |
|
|
|
detail.LocationGroup ="Random"; |
|
|
|
detail.LocationArea = "Random"; |
|
|
|
detail.CaseCode = first.CaseCode; |
|
|
|
detail.ProjCapacityCode = first.ProjCapacityCode; |
|
|
|
detail.OnceBusiCode = first.OnceBusiCode; |
|
|
|
detail.Explain = first.Explain; |
|
|
|
|
|
|
|
await SetDetailPropertiesAsync(detail).ConfigureAwait(false); |
|
|
|
detailList.Add(detail); |
|
|
|
} |
|
|
|
|
|
|
|
request.Details = detailList; |
|
|
|
await _unplannedIssueRequestManager.CreateAsync(request).ConfigureAwait(false); |
|
|
|
var dto = ObjectMapper.Map<UnplannedIssueRequest, UnplannedIssueRequestDTO>(request); |
|
|
|
return dto; |
|
|
|
return await CreateManyAsync(p_list, true).ConfigureAwait(false); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
@ -290,36 +107,6 @@ public class UnplannedIssueRequestForDongyangAppService : UnplannedIssueRequestA |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private async Task SetDetailPropertiesAsync(UnplannedIssueRequestDetail detail) |
|
|
|
{ |
|
|
|
var itemBasic = await ItemBasicAclService.GetByCodeAsync(detail.ItemCode).ConfigureAwait(false); |
|
|
|
CheckItemBasic(itemBasic, detail.ItemCode); |
|
|
|
//await CheckOnceBusiCodeAsync(detail).ConfigureAwait(false);
|
|
|
|
if (itemBasic != null) |
|
|
|
{ |
|
|
|
detail.ItemCode = itemBasic.Code; |
|
|
|
detail.ItemName = itemBasic.Name; |
|
|
|
detail.ItemDesc1 = itemBasic.Desc1; |
|
|
|
detail.ItemDesc2 = itemBasic.Desc2; |
|
|
|
detail.StdPackQty = itemBasic.StdPackQty; |
|
|
|
detail.Uom = itemBasic.BasicUom; |
|
|
|
} |
|
|
|
|
|
|
|
string packingcode = string.Empty; |
|
|
|
|
|
|
|
packingcode =string.IsNullOrEmpty(detail.PackingCode)?"99999999":detail.PackingCode; |
|
|
|
|
|
|
|
detail.PackingCode = packingcode; |
|
|
|
|
|
|
|
detail.Status = EnumInventoryStatus.OK; |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// 用来重写 导入数据时可以加工数据
|
|
|
|
/// </summary>
|
|
|
@ -431,33 +218,6 @@ public class UnplannedIssueRequestForDongyangAppService : UnplannedIssueRequestA |
|
|
|
return dictionary; |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// 创建明细
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="detail"></param>
|
|
|
|
/// <param name="balance"></param>
|
|
|
|
/// <returns></returns>
|
|
|
|
protected UnplannedIssueRequestDetail CreateNewDetail(UnplannedIssueRequestDetail detail,BalanceDTO balance) |
|
|
|
{ |
|
|
|
UnplannedIssueRequestDetail newDetail = new UnplannedIssueRequestDetail(); |
|
|
|
newDetail.ArriveDate = detail.ArriveDate; |
|
|
|
newDetail.CaseCode = detail.CaseCode; |
|
|
|
newDetail.ContainerCode = detail.ContainerCode; |
|
|
|
newDetail.Explain = detail.Explain; |
|
|
|
newDetail.ItemCode = detail.ItemCode; |
|
|
|
newDetail.LocationCode = detail.LocationCode; |
|
|
|
newDetail.Number = detail.Number; |
|
|
|
newDetail.OnceBusiCode = detail.OnceBusiCode; |
|
|
|
newDetail.ProjCapacityCode = detail.ProjCapacityCode; |
|
|
|
newDetail.ProduceDate = detail.ProduceDate; |
|
|
|
newDetail.PackingCode = balance.PackingCode; |
|
|
|
newDetail.Qty = balance.Qty; |
|
|
|
newDetail.SetIdAndNumber(GuidGenerator, detail.MasterID, detail.Number); |
|
|
|
return newDetail; |
|
|
|
} |
|
|
|
|
|
|
|
#region 赋值
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
@ -481,21 +241,19 @@ public class UnplannedIssueRequestForDongyangAppService : UnplannedIssueRequestA |
|
|
|
detail.Uom = itemBasic.BasicUom; |
|
|
|
} |
|
|
|
|
|
|
|
var location = await LocationAclService.GetByCodeAsync(detail.LocationCode).ConfigureAwait(false); |
|
|
|
CheckLocation(location, detail.LocationCode); |
|
|
|
if (location != null) |
|
|
|
{ |
|
|
|
detail.WarehouseCode = location.WarehouseCode; |
|
|
|
detail.LocationErpCode = location.ErpLocationCode; |
|
|
|
detail.LocationGroup = location.LocationGroupCode; |
|
|
|
detail.LocationArea = location.AreaCode; |
|
|
|
detail.LocationCode = location.Code; |
|
|
|
} |
|
|
|
//var location = await LocationAclService.GetByCodeAsync(detail.LocationCode).ConfigureAwait(false);
|
|
|
|
//CheckLocation(location, detail.LocationCode);
|
|
|
|
//if (location != null)
|
|
|
|
//{
|
|
|
|
// detail.WarehouseCode = location.WarehouseCode;
|
|
|
|
// detail.LocationErpCode = location.ErpLocationCode;
|
|
|
|
// detail.LocationGroup = location.LocationGroupCode;
|
|
|
|
// detail.LocationArea = location.AreaCode;
|
|
|
|
// detail.LocationCode = location.Code;
|
|
|
|
//}
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// 赋值业务事务
|
|
|
|
/// </summary>
|
|
|
@ -523,12 +281,54 @@ public class UnplannedIssueRequestForDongyangAppService : UnplannedIssueRequestA |
|
|
|
//entity.DirectCreateNote = tranType.DirectCreateNote;
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private async Task SetEntityPropertiesAsync(UnplannedIssueRequest entity) |
|
|
|
{ |
|
|
|
var userName = CurrentUser.GetUserName_New(); |
|
|
|
var name = CurrentUser.GetUserName(); |
|
|
|
if (userName != null) |
|
|
|
{ |
|
|
|
var department = await _departmentApp.GetByUsernameAsync(userName).ConfigureAwait(false); |
|
|
|
|
|
|
|
if (department != null) |
|
|
|
{ |
|
|
|
entity.DeptCode = department.Code; |
|
|
|
entity.DeptName = department.Name; |
|
|
|
} |
|
|
|
entity.CreatorId = CurrentUser.Id; |
|
|
|
entity.Worker = name; |
|
|
|
} |
|
|
|
|
|
|
|
entity.BuildDate = DateTime.Now; |
|
|
|
|
|
|
|
//await SetRequestAutoPropertiesAsync(entity).ConfigureAwait(false);
|
|
|
|
} |
|
|
|
|
|
|
|
private async Task SetDetailPropertiesAsync(UnplannedIssueRequestDetail detail) |
|
|
|
{ |
|
|
|
var itemBasic = await ItemBasicAclService.GetByCodeAsync(detail.ItemCode).ConfigureAwait(false); |
|
|
|
CheckItemBasic(itemBasic, detail.ItemCode); |
|
|
|
//await CheckOnceBusiCodeAsync(detail).ConfigureAwait(false);
|
|
|
|
if (itemBasic != null) |
|
|
|
{ |
|
|
|
detail.ItemCode = itemBasic.Code; |
|
|
|
detail.ItemName = itemBasic.Name; |
|
|
|
detail.ItemDesc1 = itemBasic.Desc1; |
|
|
|
detail.ItemDesc2 = itemBasic.Desc2; |
|
|
|
detail.StdPackQty = itemBasic.StdPackQty; |
|
|
|
detail.Uom = itemBasic.BasicUom; |
|
|
|
} |
|
|
|
|
|
|
|
string packingcode = string.Empty; |
|
|
|
|
|
|
|
packingcode = string.IsNullOrEmpty(detail.PackingCode) ? "99999999" : detail.PackingCode; |
|
|
|
|
|
|
|
detail.PackingCode = packingcode; |
|
|
|
|
|
|
|
detail.Status = EnumInventoryStatus.OK; |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
#region 校验
|
|
|
@ -549,9 +349,6 @@ public class UnplannedIssueRequestForDongyangAppService : UnplannedIssueRequestA |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
protected async Task<BalanceDTO> CheckBalanceAsync(UnplannedIssueRequestImportInput importInput, List<ValidationResult> validationRresult) |
|
|
|
{ |
|
|
|
var balance = await BalanceAclService.GetByItemLocationAndPackingAsync( |
|
|
@ -736,8 +533,74 @@ public class UnplannedIssueRequestForDongyangAppService : UnplannedIssueRequestA |
|
|
|
return await base.AbortAsync(id).ConfigureAwait(false); |
|
|
|
} |
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
#region 私有
|
|
|
|
|
|
|
|
private async Task<UnplannedIssueRequestDTO> CreateManyAsync(List<UnplannedIssueRequestImportDto> p_list, bool isAutoSubmit = false) |
|
|
|
{ |
|
|
|
UnplannedIssueRequest request = new UnplannedIssueRequest(); |
|
|
|
if (p_list.Count == 0) |
|
|
|
{ |
|
|
|
throw new UserFriendlyException("导入内容为空请填写!"); |
|
|
|
} |
|
|
|
|
|
|
|
var first = p_list.FirstOrDefault(); |
|
|
|
|
|
|
|
request.SetId(GuidGenerator.Create()); |
|
|
|
request.AutoCompleteJob = false; |
|
|
|
request.AutoSubmit = isAutoSubmit; |
|
|
|
request.AutoAgree = true; |
|
|
|
request.AutoHandle = true; |
|
|
|
request.DirectCreateNote = false; |
|
|
|
request.DeptCode = first.DeptCode; |
|
|
|
request.DeptName = first.DeptName; |
|
|
|
request.BuildDate = DateTime.Now; |
|
|
|
request.OANumber = first.OANumber; |
|
|
|
//request.Worker = first.Worker;
|
|
|
|
request.FromErpLocationCode = first.FromLocationErpCode; |
|
|
|
|
|
|
|
await SetEntityPropertiesAsync(request).ConfigureAwait(false); |
|
|
|
List<UnplannedIssueRequestDetail> detailList = new List<UnplannedIssueRequestDetail>(); |
|
|
|
foreach (var itm in p_list) |
|
|
|
{ |
|
|
|
var detail = new UnplannedIssueRequestDetail(); |
|
|
|
detail.ItemCode = itm.ItemCode; |
|
|
|
detail.Qty = itm.Qty; |
|
|
|
|
|
|
|
detail.LocationErpCode = itm.FromLocationErpCode; |
|
|
|
detail.LocationCode = "Random"; |
|
|
|
detail.WarehouseCode = "Random"; |
|
|
|
detail.LocationGroup = "Random"; |
|
|
|
detail.LocationArea = "Random"; |
|
|
|
detail.CaseCode = first.CaseCode; |
|
|
|
detail.ProjCapacityCode = first.ProjCapacityCode; |
|
|
|
detail.OnceBusiCode = first.OnceBusiCode; |
|
|
|
detail.Explain = first.Explain; |
|
|
|
detail.ExpireDate = DateTime.MaxValue; |
|
|
|
detail.FromErpLocationCode = first.FromLocationErpCode; |
|
|
|
|
|
|
|
await SetDetailPropertiesAsync(detail).ConfigureAwait(false); |
|
|
|
detailList.Add(detail); |
|
|
|
} |
|
|
|
|
|
|
|
request.Details = detailList; |
|
|
|
|
|
|
|
|
|
|
|
//var user = await _sfsUserAppService.FindUserByUserNameAsync(first.Worker).ConfigureAwait(false);
|
|
|
|
//if (string.IsNullOrEmpty(user))
|
|
|
|
//{
|
|
|
|
// throw new UserFriendlyException("没有查到用户");
|
|
|
|
//}
|
|
|
|
request.Worker = first.Worker; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
await _unplannedIssueRequestManager.CreateAsync(request).ConfigureAwait(false); |
|
|
|
var dto = ObjectMapper.Map<UnplannedIssueRequest, UnplannedIssueRequestDTO>(request); |
|
|
|
return dto; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
#endregion
|
|
|
|
} |
|
|
|