|
|
|
|
using AUCMA.STORE.Business.Interface;
|
|
|
|
|
using AUCMA.STORE.Common;
|
|
|
|
|
using AUCMA.STORE.Entity.DAO;
|
|
|
|
|
using AUCMA.STORE.Entity.DTO;
|
|
|
|
|
using AUCMA.STORE.Entity.Enums;
|
|
|
|
|
using AUCMA.STORE.SqlSugar;
|
|
|
|
|
using AUCMA.STORE.SqlSugar.serviceImpl;
|
|
|
|
|
using AutoMapper;
|
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
using System.Linq.Expressions;
|
|
|
|
|
using System.Text;
|
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
|
|
|
|
|
|
namespace AUCMA.STORE.Business.Implements
|
|
|
|
|
{
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 出入库任务队列接口实现
|
|
|
|
|
/// </summary>
|
|
|
|
|
public class BaseTaskQueueBusiness : IBaseTaskQueueBusiness
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
private readonly IBaseServices<BaseTaskQueue> baseServices = new BaseServices<BaseTaskQueue>();
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 写入任务队列
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="baseTaskQueue"></param>
|
|
|
|
|
public async Task<int> WriteTaskQueue(TaskDTO taskDTO)
|
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
Mapper.Initialize(cret => cret.CreateMap<TaskDTO, BaseTaskQueue>());
|
|
|
|
|
BaseTaskQueue baseTaskQueue = Mapper.Map<BaseTaskQueue>(taskDTO);
|
|
|
|
|
|
|
|
|
|
baseTaskQueue.uuid = System.Guid.NewGuid().ToString("N");
|
|
|
|
|
baseTaskQueue.recordTime = DateTime.Now;
|
|
|
|
|
var info = await baseServices.Add(baseTaskQueue);
|
|
|
|
|
return info;
|
|
|
|
|
}catch(Exception ex)
|
|
|
|
|
{
|
|
|
|
|
LogHelper.Error("写入任务队列异常", ex);
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 获取任务队列
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="baseTaskQueue"></param>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
public async Task<BaseTaskQueue> GetTaskQueue(LocationArea locationArea, TaskType taskType, OperationType operationType)
|
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
Expression<Func<BaseTaskQueue, bool>> exp = s1 => true;
|
|
|
|
|
Expression<Func<BaseTaskQueue, object>> order = (x) => x.recordTime;
|
|
|
|
|
//exp = exp.And(s1 => s1.locationArea == locationArea && s1.pilerTaskType == taskType && s1.operationType == operationType && s1.storeCode == ConfigHelper.GetConfig("storeCode"));
|
|
|
|
|
|
|
|
|
|
exp = exp.And(s1 => s1.pilerTaskType == taskType && s1.operationType == operationType && s1.storeCode == ConfigHelper.GetConfig("storeCode"));
|
|
|
|
|
if (taskType == TaskType.InStore)
|
|
|
|
|
{
|
|
|
|
|
exp = exp.And(s1 => s1.locationArea == locationArea);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if(taskType == TaskType.OutStore)
|
|
|
|
|
{
|
|
|
|
|
if(operationType == OperationType.ManualOperation)
|
|
|
|
|
{
|
|
|
|
|
exp = exp.And(s1 => s1.locationArea == locationArea);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//var outStoreType = iNIFile.IniReadValue("系统设置", "出库方式");
|
|
|
|
|
//if(outStoreType == "2")
|
|
|
|
|
//{
|
|
|
|
|
// if(taskType == TaskType.OutStore)
|
|
|
|
|
// {
|
|
|
|
|
// exp = exp.And(s1 => s1.locationArea == locationArea);
|
|
|
|
|
// }
|
|
|
|
|
//}
|
|
|
|
|
|
|
|
|
|
List<BaseTaskQueue> baseTaskQueues = await baseServices.Query(exp, order, true);
|
|
|
|
|
|
|
|
|
|
return baseTaskQueues.FirstOrDefault();
|
|
|
|
|
}catch(Exception ex)
|
|
|
|
|
{
|
|
|
|
|
LogHelper.Error("获取任务队列异常", ex);
|
|
|
|
|
return new BaseTaskQueue();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 清除任务队列
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="baseTaskQueue"></param>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
public async Task<bool> DeleteTaskQueue(BaseTaskQueue baseTaskQueue)
|
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
return await baseServices.Delete(baseTaskQueue);
|
|
|
|
|
}catch(Exception ex)
|
|
|
|
|
{
|
|
|
|
|
LogHelper.Error("清除任务队列异常", ex);
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 清除指定任务
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="taskCode"></param>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
public async Task<bool> DeleteAssignTask(string taskCode)
|
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
Expression<Func<BaseTaskQueue, bool>> exp = s1 => true;
|
|
|
|
|
//Expression<Func<BaseTaskQueue, object>> order = (x) => x.recordTime;
|
|
|
|
|
exp = exp.And(s1 => s1.pilerTaskCode == taskCode && s1.storeCode == ConfigHelper.GetConfig("storeCode"));
|
|
|
|
|
List<BaseTaskQueue> baseTaskQueues = await baseServices.Query(exp);
|
|
|
|
|
baseTaskQueues.ForEach(x =>
|
|
|
|
|
{
|
|
|
|
|
baseServices.Delete(x);
|
|
|
|
|
});
|
|
|
|
|
return true;
|
|
|
|
|
}catch(Exception ex)
|
|
|
|
|
{
|
|
|
|
|
LogHelper.Error("清除指定任务异常", ex);
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 获取所有符合条件的任务集合
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="locationArea"></param>
|
|
|
|
|
/// <param name="taskType"></param>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
public async Task<List<BaseTaskQueue>> GetTaskQueueList()
|
|
|
|
|
{
|
|
|
|
|
Expression<Func<BaseTaskQueue, bool>> exp = s1 => true;
|
|
|
|
|
exp = exp.And(x => x.storeCode.Equals(ConfigHelper.GetConfig("storeCode")));
|
|
|
|
|
List<BaseTaskQueue> info = await baseServices.Query(exp);
|
|
|
|
|
info.ForEach(x =>
|
|
|
|
|
{
|
|
|
|
|
LogHelper.Info("队列初始化查询" + JsonChange.ModeToJson(x));
|
|
|
|
|
});
|
|
|
|
|
return info;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|