Commit 4fbd0a71 by zhaojinzhan

发起盘点接口修改

parent c00ab9c3
using System;
using System.Collections.Generic;
using System.Text;
namespace Domain.TakeStock
{
public class ReturnPlanDto
{
public bool IsSuccess { get; set; }
public string Message { get; set; }
}
}
......@@ -13,7 +13,7 @@ namespace IService.TakeStock
/// </summary>
/// <param name="record"></param>
/// <returns></returns>
Task<bool> CreateTakeStockOrderAsync(TakeStockSchedule record, List<TakeStockOrder> orders);
Task<ReturnPlanDto> CreateTakeStockOrderAsync(TakeStockSchedule record, List<TakeStockOrder> orders);
Task<bool> ReTry(int scheduleId);
......
......@@ -45,21 +45,30 @@ namespace Service.TakeStock
/// </summary>
/// <param name="schedule"></param>
/// <returns></returns>
public async Task<bool> CreateTakeStockOrderAsync(TakeStockSchedule schedule, List<TakeStockOrder> orders)
public async Task<ReturnPlanDto> CreateTakeStockOrderAsync(TakeStockSchedule schedule, List<TakeStockOrder> orders)
{
return await Task.Run(() =>
return await Task.Factory.StartNew<ReturnPlanDto>(() =>
{
string[] skus = orders.Select(o => o.Sku).ToArray();
if (schedule.IsAutomation)
{
int count = _orderRepository.Count(o => o.WarehouseCode.Equals(schedule.WarehouseCode) && skus.Contains(o.Sku) && o.State != TSOrderState.取消 && o.State != TSOrderState.完成); //&& o.CreationTime > DateTime.Now.AddDays(-1)
if (count > 0) return false;
Expression<Func<TakeStockOrder, bool>> predicate = o => o.WarehouseCode.Equals(schedule.WarehouseCode) && skus.Contains(o.Sku) && o.State != TSOrderState.取消 && o.State != TSOrderState.完成;
int count = _orderRepository.Count(predicate); //&& o.CreationTime > DateTime.Now.AddDays(-1)
if (count > 0)
{
// 如果发现有存在的记录再查询这些记录返回单号
var existIds = _orderRepository.GetAllList(predicate).Select(t => t.ScheduleId).ToArray();
var exisPlanCodes = _scheduleRepository.GetAllList(t => existIds.Contains(t.Id)).Select(t => t.Code).ToArray();
return new ReturnPlanDto() { IsSuccess = false, Message = $"存在盘点计划单号未处理:{string.Join(',', exisPlanCodes)}" };
}
}
int scheduleId = _scheduleRepository.CreateOrder(schedule, orders);
if (scheduleId > 0)
BackgroundJob.Enqueue(() => ReTry(scheduleId));
return scheduleId > 0;
return new ReturnPlanDto() { IsSuccess = true, Message = "" };
});
}
......
......@@ -2,6 +2,7 @@
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Domain.TakeStock;
using IService.TakeStock;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Http;
......@@ -45,7 +46,7 @@ namespace TakeStock.API.Controllers
//}
[HttpPost]
public async Task<bool> CreateTakeStockSchedule([FromBody] ScheduleInputDto record)
public async Task<ReturnPlanDto> CreateTakeStockSchedule([FromBody] ScheduleInputDto record)
{
var result = await takeStockAppService.CreateTakeStockSchedule(record);
return result;
......
......@@ -24,7 +24,7 @@ namespace TakeStock.Application.TakeStock
this.takeStockService = takeStockService;
}
public async Task<bool> CreateTakeStockSchedule(ScheduleInputDto input)
public async Task<ReturnPlanDto> CreateTakeStockSchedule(ScheduleInputDto input)
{
var str = JsonConvert.SerializeObject(input);
TakeStockSchedule schedule = JsonConvert.DeserializeObject<TakeStockSchedule>(str);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment