|
using Microsoft.AspNetCore.Http;
|
using Microsoft.Extensions.DependencyInjection;
|
using System.Linq;
|
using WIDESEA_Common.LoctionEnum;
|
using WIDESEA_Core.EFDbContext;
|
using WIDESEA_Core.Utilities;
|
using WIDESEA_Entity.DomainModels;
|
using WIDESEA_Entity.DomainModels.CacheTask;
|
using WIDESEA_Entity.DomainModels.CacheTask.WIDESEA_Entity.DomainModels;
|
using WIDESEA_Services.IRepositories;
|
using WIDESEA_Services.Repositories;
|
|
namespace WIDESEA_Services.Services
|
{
|
public partial class VV_ContainerInfoService
|
{
|
private readonly IHttpContextAccessor _httpContextAccessor;
|
private readonly IVV_ContainerInfoRepository _repository;//访问数据库
|
|
[ActivatorUtilitiesConstructor]
|
public VV_ContainerInfoService(
|
IVV_ContainerInfoRepository dbRepository,
|
IHttpContextAccessor httpContextAccessor
|
)
|
: base(dbRepository)
|
{
|
_httpContextAccessor = httpContextAccessor;
|
_repository = dbRepository;
|
//多租户会用到这init代码,其他情况可以不用
|
//base.Init(dbRepository);
|
}
|
public override WebResponseContent Del(object[] keys, bool delList = true)
|
{
|
WebResponseContent content = new WebResponseContent();
|
try
|
{
|
VV_ContainerInfo vV_Container= VV_ContainerInfoRepository.Instance.Find(d => d.container_id.ToString() == keys[0].ToString()).FirstOrDefault();
|
VOLContext Context = new VOLContext();
|
Ibase_pda_locationRepository Pda_LocationRepository = new base_pda_locationRepository(Context);
|
Idt_agvtaskRepository agvtaskRepository=new dt_agvtaskRepository(Context);
|
Idt_containerRepository containerRepository= new dt_containerRepository(Context);
|
if (vV_Container!=null)
|
{
|
|
base_pda_location Pda_Location= Pda_LocationRepository.FindFirst(d=>d.L_Code== vV_Container.L_Code);
|
if (Pda_Location!=null)
|
{
|
dt_agvtask dt_Agvtask = agvtaskRepository.FindFirst(d => d.agv_fromaddress == Pda_Location.L_Code || d.agv_toaddress == Pda_Location.L_Code);
|
if (dt_Agvtask==null)
|
{
|
|
|
dt_container dt_Container = containerRepository.FindFirst(d => d.container_id == vV_Container.container_id);
|
|
Pda_Location.L_state = LoctionStateEnum.LocationState_Empty.ToString();
|
Pda_Location.L_Task = 2;
|
Pda_LocationRepository.Update(Pda_Location,true);
|
containerRepository.Delete(dt_Container,true);
|
return content.OK("删除成功");
|
}
|
else
|
{
|
return content.Error("AGV任务中存在,无法删除");
|
|
}
|
|
|
}
|
else
|
{
|
return content.Error($"pda货位列表中未找到{Pda_Location.L_Code}");
|
}
|
|
}
|
}
|
catch (System.Exception)
|
{
|
|
throw;
|
}
|
return base.Del(keys, delList);
|
}
|
}
|
}
|